import os
import sys

# 添加项目根目录到Python路径
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..'))

from config_reader import get_langsmith_config
from langchain_openai import ChatOpenAI

# 从配置文件读取LangSmith配置
langsmith_config = get_langsmith_config()

# 设置环境变量
os.environ["LANGCHAIN_TRACING_V2"] = langsmith_config['tracing_v2']
os.environ["LANGCHAIN_ENDPOINT"] = langsmith_config['endpoint']
os.environ["LANGCHAIN_PROJECT"] = langsmith_config['project']
os.environ["LANGCHAIN_API_KEY"] = langsmith_config['api_key']

# 调用大语言模型
# 创建模型
model = ChatOpenAI(model='gpt-4o-mini')
resp = model.invoke("Hello, world!")
print(resp.content)
